<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者，助力中小企业发展 
+----------------------------------------------------------------------
| Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
+----------------------------------------------------------------------
| 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
+----------------------------------------------------------------------
| 组件-价格明细 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->

<template>
	<view class="container" @click="closePage()">
		<view class="container-popup" @click.stop>
			<view class="popup-header">
				<view class="title">预估费用明细</view>
				<image class="close" src="/static/close.png" mode="aspectFit" @click="closePage()"></image>
			</view>
			<view class="popup-content">
				<scroll-view scroll-y class="contetnt-scroll">
					<view class="scroll-list">
						<view class="list-item" v-for="(item, index) in amountDetails" :key="index">
							<view class="item-info flex align-items-center">
								<view class="info-title">{{item.title}}</view>
								<view class="info-price flex-item">
									<text v-if="parseFloat(item.price) < 0" style="color: #DE2828;">{{parseFloat(item.price).toFixed(2)}}元</text>
									<text v-else>{{parseFloat(item.price).toFixed(2)}}元</text>
								</view>
							</view>
							<view class="item-desc">{{item.desc}}</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<view class="popup-btn">
				<view class="btn" :style="{background: themeColor}" @click="onConfirm()">查看代驾计价规则</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState } from "vuex"
	export default {
		name: "componentModalAmountDetails",
		data() {
			return {
				// 价格明细
				amountDetails: [],
				// 当前城市
				currentCity: "",
			}
		},
		computed: {
			...mapState({
				themeColor: state => state.app.themeColor,
			})
		},
		onLoad(option) {
			this.amountDetails = JSON.parse(option.data)
			this.currentCity = option.city
		},
		methods: {
			// 关闭页面
			closePage() {
				if (getCurrentPages().length == 1) {
					this.$util.toPage({
						mode: 3,
						path: "/pages/driver/index/index"
					})
				} else {
					uni.navigateBack()
				}
			},
			// 确认
			onConfirm() {
				this.$util.toPage({
					mode: 2,
					path: "/pages/driver/order/pricingRules?city=" + this.currentCity,
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: transparent;
	}

	.container {
		width: 100vw;
		height: 100vh;
		display: flex;
		justify-content: center;
		align-items: flex-end;
		background: rgba(0, 0, 0, 0.50);

		.container-popup {
			flex: 1;
			background: #FFF;
			border-radius: 32rpx 32rpx 0 0;
			padding-top: 32rpx;

			.popup-header {
				display: flex;
				align-items: center;
				padding: 0 48rpx 0 96rpx;

				.title {
					color: #242629;
					text-align: center;
					font-size: 32rpx;
					font-weight: 600;
					line-height: 44rpx;
					flex: 1;
				}

				.close {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.popup-content {
				padding: 12rpx 32rpx 32rpx;

				.contetnt-scroll {
					overflow: hidden;
					max-height: 60vh;
					min-height: 20vh;

					.scroll-list {
						padding: 0 16rpx;

						.list-item {
							margin-top: 32rpx;

							.item-info {
								.info-title {
									color: #000;
									font-size: 32rpx;
									font-weight: 600;
									line-height: 44rpx;
								}

								.info-price {
									color: #000;
									font-size: 32rpx;
									font-weight: 600;
									line-height: 44rpx;
									text-align: right;
								}
							}

							.item-desc {
								margin-top: 16rpx;
								color: #8D929C;
								font-size: 28rpx;
								font-weight: 600;
								line-height: 40rpx;
							}
						}
					}
				}
			}

			.popup-btn {
				padding: 16rpx 48rpx;

				.btn {
					color: #FFFFFF;
					font-size: 28rpx;
					line-height: 40rpx;
					text-align: center;
					padding: 28rpx;
					border-radius: 48rpx;
				}
			}
		}
	}
</style>